<?php

class Faculty{

	public $id;
	public $name;
	public $desc;
	public $image;
	public $department;
	public $diploma;
	
	public static function getMaxId(){
		$query = 'SELECT Max(Id) as maxId FROM faculty';
		return getQueryObject($query);
	}
	
	public static function getCountRow(){
		$query = 'SELECT count(*) as countRow FROM faculty';
		return getQueryObject($query);
	}
	
	public static function getFaculty(){
		$query = "SELECT Id, Name, `Desc`, Image, Department, Diploma, Process, Performance  FROM faculty";
		return getQueryArray($query);
	}
	
	public static function getFacultyById($id){
		$query = "SELECT Id, Name, `Desc`, Image, Department, Diploma, Process, Performance FROM faculty WHERE Id={$id}";
		return getQueryObject($query);
	}
	
	public static function getFacultyByLimit($from, $to){
		$query = "SELECT Id, Name, `Desc`, Image, Department, Diploma, Process, Performance FROM faculty LIMIT {$from}, {$to}";
		return getQueryArray($query);
	}
	
	public static function insertFaculty($name, $desc, $image, $department, $diploma, $process, $performance){
		$query = "INSERT INTO faculty(Name, `Desc`, Image, Department, Diploma, Process, Performance) values ('{$name}', '{$desc}', '{$image}', '{$department}', '{$diploma}', '{$process}', '{$performance}')";
		getQueryUpdate($query);
	}
	
	public static function updateFaculty($id, $name, $desc, $image, $department, $diploma, $process, $performance){
		$query = "UPDATE faculty SET Name='{$name}', `Desc`='{$desc}', Image='{$image}', Department='{$department}', Diploma='{$diploma}', Process='{$process}', Performance='{$performance}' WHERE Id={$id}";
		getQueryUpdate($query);
	}
	
	public static function updateFacultyWithoutImage($id, $name, $desc, $department, $diploma, $process, $performance){
		$query = "UPDATE faculty SET Name='{$name}', `Desc`='{$desc}', Department='{$department}', Diploma='{$diploma}', Process='{$process}', Performance='{$performance}' WHERE Id={$id}";
		getQueryUpdate($query);
	}
	
	public static function deleteFaculty($id){
		$query = "DELETE FROM faculty WHERE Id={$id}";
		getQueryUpdate($query);
	}
}
?>